package com.ruoyi.project.module.lyq;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.project.domain.YqgInformationProject;
import com.ruoyi.project.service.IYqgInformationProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 项目信息Controller
 * 
 * @author dr
 * @date 2023-04-17
 */
@RestController
@RequestMapping("/lyq/project")
public class LyqYqgInformationProjectController extends BaseController
{
    @Autowired
    private IYqgInformationProjectService yqgInformationProjectService;

    /**
     * 查询项目信息列表
     */
//    @RequiresPermissions("project:project:list")
    @GetMapping("/list")
    public TableDataInfo list(YqgInformationProject yqgInformationProject)
    {
        startPage();
        List<YqgInformationProject> list = yqgInformationProjectService.selectYqgInformationProjectList(yqgInformationProject);
        return getDataTable(list);
    }

    /**
     * 导出项目信息列表
     */
//    @RequiresPermissions("project:project:export")
    @Log(title = "项目信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqgInformationProject yqgInformationProject)
    {
        List<YqgInformationProject> list = yqgInformationProjectService.selectYqgInformationProjectList(yqgInformationProject);
        ExcelUtil<YqgInformationProject> util = new ExcelUtil<YqgInformationProject>(YqgInformationProject.class);
        util.exportExcel(response, list, "项目信息数据");
    }

    /**
     * 获取项目信息详细信息
     */
//    @RequiresPermissions("project:project:query")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID)
    {
        return success(yqgInformationProjectService.selectYqgInformationProjectByID(ID));
    }

    /**
     * 新增项目信息
     */
//    @RequiresPermissions("project:project:add")
    @Log(title = "项目信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqgInformationProject yqgInformationProject)
    {
        return toAjax(yqgInformationProjectService.insertYqgInformationProject(yqgInformationProject));
    }

    /**
     * 修改项目信息
     */
//    @RequiresPermissions("project:project:edit")
    @Log(title = "项目信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqgInformationProject yqgInformationProject)
    {
        return toAjax(yqgInformationProjectService.updateYqgInformationProject(yqgInformationProject));
    }

    /**
     * 删除项目信息
     */
//    @RequiresPermissions("project:project:remove")
    @Log(title = "项目信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs)
    {
        return toAjax(yqgInformationProjectService.deleteYqgInformationProjectByIDs(IDs));
    }
}
